package calendar;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import org.apache.commons.lang.time.DateFormatUtils;
import org.junit.Test;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder;
import com.thoughtworks.xstream.io.xml.XppDriver;

import freemarker.template.utility.DateUtil;

/**
 * d
 * @author fqcd
 *
 * 2018年5月11日下午4:08:35
 */
public class add {
	
	/**
	 * xstream使用
	 */
	@Test
	public void xStream() {
		Person person = new Person();
		Person person2 = new Person();
		person.setD_ate(new Date());
		person2.setD_ate(new Date());
		person.setName("张飞");
		person.setName("关羽");
		
		ArrayList<Person> arrayList = new ArrayList<Person>();
		arrayList.add(person);
		arrayList.add(person2);
	
		XStream xStream = new XStream(new XppDriver(new XmlFriendlyNameCoder("_-", "_")));
		xStream.alias("fff", Person.class);
//		//注解检测.使用此注解后alias失效
		xStream.autodetectAnnotations(true); 
		

		
		
		String xml = xStream.toXML(arrayList);
		
		System.out.println(xml);
		
	}
	/**
	 * gson使用说明
	 */
	@Test
	public void gson() {
		
		Student2 student = new Student2();
		student.setAge(12);
		student.setName("张三");
		student.setBirthday(new Date());
		Gson gson2 = new Gson();
		Gson gson = new GsonBuilder().setPrettyPrinting().create();
	String json = gson2.toJson(student);
	System.out.println(json);

		
		
	}
}